const {categoryModule} = require('../Model.js')
const redis = require('../../../redis/init.js')
const categoryControl = async  (req,res)=>{
    const categoryListExists = await redis.exists(req.originalUrl);
    if(categoryListExists){
        const categoryList = await redis.get(req.originalUrl)
        res.send(categoryList)
    }else{
        categoryModule.findAll().then(result=>{
        redis.set(req.originalUrl,JSON.stringify(result))
        res.send(result)
    })
    }
 
}
module.exports = categoryControl